package com.leetcode.easy;

import java.util.HashMap;

public class TwoSum {
    public int[] twoSum(int[] nums, int target) {
        HashMap<Integer, Integer> hashMap = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            Integer integer = hashMap.get(target - nums[i]);
            hashMap.put(nums[i], i);
            if (integer != null){
                return new int[]{integer, i};
            }
        }
        return null;
    }
}
